package com.nulldev.util.networking.ip;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Iterator;

import com.nulldev.util.JVM.JVM;
import com.nulldev.util.networking.dns.client.Message;
import com.nulldev.util.networking.dns.client.record.Record;
import com.nulldev.util.networking.dns.client.transport.Resolver;

public class DNS {

	public static String[] resolve(final String domain) throws IOException {
		final Resolver r = new Resolver(new InetSocketAddress("8.8.8.8", 53).getAddress());
		final Message m = r.request(domain);
		JVM.println(m);
		final Record[] records = new Record[m.getAnswers().size()];
		final Iterator<Record> ite = m.getAnswers().iterator();
		for (int i = 0; i < records.length; i++) {
			records[i] = ite.next();
		}
		return null;
	}

	public static void main(String[] args) throws IOException {
		resolve("www.google.com");
	}
}
